<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>nth-child和nth-of-type的区别</title>
    <style>
    /* nth-child(n)   第几个
       nth-of-type(n) 第几个
       总结：  子元素标签统一的  - nth-child(n) / nth-of-type(n)
              子元素标签不统一  - nth-of-type(n)  筛选 span  - 偶数行
    */
    .box span:nth-child(2n){
        display: block;
        background-color: red;
    }

    /* .box span:nth-of-type(2n){
        display: block;
        background-color: red;
    } */
    </style>
</head>

<body>
    <section class="box">
        <p>我是第1个p标签</p>
        <span>1</span>
        <p>我是第2个p标签</p>
        <span>2</span>
        <p>我是第3个p标签</p>
        <span>3</span>
        <p>我是第4个p标签</p>
        <span>4</span>
        <p>我是第5个p标签</p>
        <span>5</span>

    </section>
</body>

</html>